#ifndef PWAVE_MPIIO_H
#define PWAVE_MPIIO_H

#include <vector>
#include <mpi.h>

#include "swt_env_win_linux.h"
#include "lct_env_macros.h"
#include "FileManagement.h"
#include "Data3D.h"
#include "MPI_TopoCart2D.h"
#include "Miscellaneous_structs.h"


class MPIIO {
private:
    int buff_p;         // buff_p is always identical for each outputting points in a block
public:
    const int buff_size;


    MPIIO();

    void read_yz_block(double* dst, const char* path, const Data3D* data3D, const MPI_TopoCart2D* topo);
    void blk3D2arr(double* dst, const std::string& out_dir_iden, bool raw, const Data3D* data3D, const MPI_TopoCart2D* topo);
    void blk3Dslice_x(double* dst, const std::string& name, bool raw, const Data3D* data3D, const MPI_TopoCart2D* topo, int target_x);
    void blk3Dslice_y(double* dst, const std::string& name, bool raw, const Data3D* data3D, const MPI_TopoCart2D* topo, int target_y);
    void blk3Dslice_z(double* dst, const std::string& name, bool raw, const Data3D* data3D, const MPI_TopoCart2D* topo, int target_y);
    void out_coord_val(const double* dst, double* buffer, const std::vector<OutputPtInfo>& out_pt_info);
    void flush_buffer(double* buffer, const std::vector<OutputPtInfo>& out_pt_info);
};

#endif //PWAVE_MPIIO_H
